package com.df.blueben.controller;

import com.df.blueben.common.BaseResponse;
import com.df.blueben.common.ResultUtils;
import com.df.blueben.model.dto.note.NoteAddDto;
import com.df.blueben.model.dto.note.NoteSearchDto;
import com.df.blueben.model.vo.Note.NoteDetailVo;
import com.df.blueben.model.vo.Note.NoteVo;
import com.df.blueben.model.vo.PageVo;
import com.df.blueben.service.NotesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/note")
public class NoteController {

    @Autowired
    NotesService notesService;
    @PostMapping("/add")
    public BaseResponse<?> addNote(@RequestBody NoteAddDto addDto){
        notesService.addNote(addDto);
        return ResultUtils.success(null);
    }

    @GetMapping("/search")
    public BaseResponse<PageVo> searchNote(NoteSearchDto searchDto){
        return ResultUtils.success(notesService.searchNotes(searchDto));
    }

    @GetMapping("/detail/{id}")
    public BaseResponse<NoteDetailVo> detailNote(@PathVariable("id") Long id){
        NoteDetailVo noteDetailVo = notesService.detailNote(id);
        return ResultUtils.success(noteDetailVo);
    }
}
